
import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';


export class BaseCourseDto{
  @ApiProperty({required: false , description: '课程ID'})
  @IsOptional()
  @IsNumber()
  courseId?: number;

  @ApiProperty({enum: CharEnum, required: false , description: '删除标志'})
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({enum: CharEnum, required: false , description: '状态'})
  @IsOptional()
  @IsString()
  status?: string;

  @ApiProperty({required: false , description: '创建者'})
  @IsOptional()
  @IsString()
  createBy?: string;

  @ApiProperty({required: false , description: '创建时间'})
  @IsOptional()
  @IsString()
  createTime?: string;

  @ApiProperty({required: false , description: '更新者'})
  @IsOptional()
  @IsString()
  updateBy?: string;

  @ApiProperty({required: false , description: '更新时间'})
  @IsOptional()
  @IsString()
  updateTime?: string;

  @ApiProperty({required: false , description: '备注'})
  @IsOptional()
  @IsString()
  remark?: string;

  @ApiProperty({required: true , description: '课程名称'})
  @IsString()
  courseName: string;

  @ApiProperty({required: true , description: '课程介绍'})
  @IsString()
  courseIntroduce: string;

  @ApiProperty({required: true , description: '课程时长'})
  @IsOptional()
  @IsNumber()
  courseTime: number;

}

export class CreateCourseDto extends OmitType(BaseCourseDto, [ 'courseId', 'delFlag']){}

export class UpdateCourseDto extends OmitType(BaseCourseDto, [ 'delFlag', 'createBy', 'createTime']){}

export class QueryCourseDto extends IntersectionType( BaseCourseDto, PagingDto){
  @ApiProperty({required: true , description: '课程名称'})
  @IsOptional()
  @IsString()
  courseName: string;

  @ApiProperty({required: true , description: '课程介绍'})
  @IsOptional()
  @IsString()
  courseIntroduce: string;
}

export class ListCourseDto  extends OmitType(BaseCourseDto, [ 'courseId', 'delFlag', 'createBy', 'createTime', 'updateBy', 'updateTime']) {}
